/*
 * Set.h
 *
 *  Created on: 2012-12-25
 *      Author: yangentao@gmail.com
 */

#pragma once;
#include <set>

using namespace std;

namespace yet {

template<typename T>
class Set {
public:
	Set() {
	}
	virtual ~Set() {
	}
public:
	void put(T element) {
		elements.insert(element);
	}
	void remove(T element) {
		elements.erase(element);
	}
	void clear() {
		elements.clear();
	}
	bool empty(){
		return elements.empty();
	}
	bool contains(T value) {
		return elements.find(value) != elements.end();
	}
	bool has(T value) {
		return elements.find(value) != elements.end();
	}
	bool isIntersect(const Set& other) {
		set<int>::const_iterator i = other.elements.begin();
		for (; i != other.elements.end(); ++i) {
			if (elements.find(*i) != elements.end()) {
				return true;
			}
		}
		return false;
	}
	bool containsAll(const Set& other) {
		set<int>::const_iterator i = other.elements.begin();
		for (; i != other.elements.end(); ++i) {
			if (elements.find(*i) == elements.end()) {
				return false;
			}
		}
		return true;
	}

public:
	set<T> elements;
};

} /* namespace yet */
